import '../models/emotion_record.dart';
import '../models/analytics_models.dart';
import '../models/statistics_summary.dart' as stats;

/// 情绪记录数据仓库接口
/// Emotion record repository interface
abstract class EmotionRepository {
  /// 获取所有情绪记录
  /// Get all emotion records
  Future<List<EmotionRecord>> getAllRecords();
  
  /// 根据日期范围获取情绪记录
  /// Get emotion records by date range
  Future<List<EmotionRecord>> getRecordsByDateRange({
    required DateTime startDate,
    required DateTime endDate,
  });
  
  /// 根据ID获取单个情绪记录
  /// Get single emotion record by ID
  Future<EmotionRecord?> getRecordById(String id);
  
  /// 获取今日的情绪记录
  /// Get today's emotion records
  Future<List<EmotionRecord>> getTodayRecords();
  
  /// 获取最近的情绪记录
  /// Get recent emotion records
  Future<List<EmotionRecord>> getRecentRecords({int limit = 10});
  
  /// 插入新的情绪记录
  /// Insert new emotion record
  Future<String> insertRecord(EmotionRecord record);
  
  /// 更新情绪记录
  /// Update emotion record
  Future<void> updateRecord(EmotionRecord record);
  
  /// 删除情绪记录
  /// Delete emotion record
  Future<void> deleteRecord(String id);
  
  /// 批量删除情绪记录
  /// Batch delete emotion records
  Future<void> deleteRecords(List<String> ids);
  
  /// 获取情绪趋势数据
  /// Get emotion trend data
  Future<List<EmotionTrend>> getEmotionTrends({
    required DateRange dateRange,
  });
  
  /// 获取情绪分布数据
  /// Get emotion distribution data
  Future<List<EmotionDistribution>> getEmotionDistribution({
    required DateRange dateRange,
  });
  
  /// 获取词频数据
  /// Get word frequency data
  Future<List<WordFrequency>> getWordFrequencies({
    required DateRange dateRange,
    int limit = 50,
  });
  
  /// 获取统计摘要
  /// Get statistics summary
  Future<stats.StatisticsSummary> getStatisticsSummary();
  
  /// 搜索情绪记录
  /// Search emotion records
  Future<List<EmotionRecord>> searchRecords({
    required String keyword,
    EmotionType? emotionType,
    DateRange? dateRange,
  });
  
  /// 获取记录总数
  /// Get total record count
  Future<int> getRecordCount();
  
  /// 分页获取情绪记录
  /// Get emotion records with pagination
  Future<List<EmotionRecord>> getRecordsPaginated({
    required int page,
    required int pageSize,
  });
  
  /// 检查今日是否已有记录
  /// Check if there are records today
  Future<bool> hasTodayRecords();
  
  /// 获取连续记录天数
  /// Get consecutive recording days
  Future<int> getConsecutiveRecordingDays();
  
  /// 导出所有数据
  /// Export all data
  Future<Map<String, dynamic>> exportAllData();
  
  /// 清空所有数据
  /// Clear all data
  Future<void> clearAllData();
}

/// 媒体文件数据仓库接口
/// Media file repository interface
abstract class MediaRepository {
  /// 根据记录ID获取媒体文件
  /// Get media files by record ID
  Future<List<MediaFile>> getMediaFilesByRecordId(String recordId);
  
  /// 插入媒体文件
  /// Insert media file
  Future<String> insertMediaFile(MediaFile mediaFile);
  
  /// 删除媒体文件
  /// Delete media file
  Future<void> deleteMediaFile(String id);
  
  /// 根据记录ID删除所有媒体文件
  /// Delete all media files by record ID
  Future<void> deleteMediaFilesByRecordId(String recordId);
  
  /// 获取媒体文件总大小
  /// Get total media file size
  Future<int> getTotalMediaFileSize();
  
  /// 清理无效的媒体文件
  /// Clean up invalid media files
  Future<void> cleanupInvalidMediaFiles();
}